package com.yunang.officialweb.service.impl;

import com.yunang.officialweb.entity.Department;
import com.yunang.officialweb.entity.PageOfDepartMent;
import com.yunang.officialweb.entity.TotalDesc;
import com.yunang.officialweb.mapper.DepMapper;
import com.yunang.officialweb.service.DepService;
import com.yunang.officialweb.service.TotalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author duan
 * @date 2022/11/29 21:15
 */
@Service
public class DepServiceImpl implements DepService {

    @Autowired
    private DepMapper depMapper;

    @Autowired
    private TotalService totalService;

    @Override
    public Department selectById(int id) {
        return depMapper.selectById(id);
    }

    @Override
    public List<Department> findAll() {
        return depMapper.findAll();
    }

    @Override
    public PageOfDepartMent selectPage() {
        int id = 1;
        PageOfDepartMent pageOfDepartMent = new PageOfDepartMent();
        pageOfDepartMent.setViewDesc(totalService.selectById(id));
        pageOfDepartMent.setDepartment(depMapper.findAll());

        return pageOfDepartMent;
    }

    @Override
    public Boolean updateDep(Department department) {
        return depMapper.updateDep(department);
    }
}
